const Controller = require('egg').Controller;

class UserController extends Controller {
  // login / true
  async login() {
    const { ctx, app } = this;
    const data = await ctx.service.user.login()
    ctx.body = data
  }
  async register() {
    const { ctx, app } = this;
    ctx.body = 'register'
  }

  async myUrl() {
    console.log(this.ctx.state)

    if (this.ctx.state.user.userid === 0) {
      this.ctx.body = {
        code: 0,
        data: [
          '/homeIndex/table',
          '/homeIndex/list',
          '/homeIndex/form',
          '/homeIndex/echarts',
        ]
      }
    } else {
      this.ctx.body = {
        code: 0,
        data: [
          '/homeIndex/table',
          '/homeIndex/echarts',
        ]
      }
    }
  }
}

module.exports = UserController;